home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1994 December
/
PSL Monthly Shareware CD-ROM (Public Software Library)(December 1994).bin
/
prgmming
/
dos
/
asm
/
m8087.mac
< prev
next >
Wrap
Text File
|
1984-08-27
|
29KB
|
823 lines
;**********************************************************************;
; ;
; M8087.MAC - File of macros which provide assembly level ;
; software support for use of 8087 NDP with ;
; the IBM personal computer. ;
; ;
;**********************************************************************;
if1 ; do not include this file in any output listing
;**********************************************************************;
; ;
; ESC_REG - "REG" parameter specifies ESC value. Issue proper ;
; ESC sequence depending on REG value. PARAM is a ;
; 6-bit parameter whose upper 3-bits make up the ;
; "xxx" bits in the ESC opcode (11011xxx) and lower ;
; 3-bits make up "yyy~ bits in source byte following ;
; (using standard "mod" and "r/m" designators define ;
; byte as "modyyyr/m"). ;
; ;
;**********************************************************************;
ESC_REG macro PARAM,REG
;
; We need to determine what "reg" field assignment correspnds with
; the current value of REG. This is used as the source for the
; ESC operation. PARAM is used directly in the ESC call.
;
ife REG ; Decrement until REG = 0, then issue ESC sequence
ESC PARAM,AX ; AX = 000b (see operand summary for 8088)
else
REG = REG - 1
ife REG
ESC PARAM,CX ; CX = 001b
else
REG = REG - 1
ife REG
ESC PARAM,DX ; DX = 010b
else
REG = REG - 1
ife REG
ESC PARAM,BX ; BX = 011b
else
REG = REG - 1
ife REG
ESC PARAM,SP ; SP = 100b
else
REG = REG - 1
ife REG
ESC PARAM,BP ; BP = 101b
else
REG = REG - 1
ife REG
ESC PARAM,SI ; SI = 110b
else ; If REG >= 7, assume 7
ESC PARAM,DI ; DI = 111b
endif
endif
endif
endif
endif
endif
endif
endm ; Done with ESC_REG macro
;**********************************************************************;
; ;
; CHECK_ST - Inputs parameter "ST(i)" and returns with REG=i ;
; ;
;**********************************************************************;
CHECK_ST macro P_ST
REG = -1 ; Assume no match is found
ifidn <&P_ST>,<ST(0)> ; Is i=0?
REG = 0
endif
ifidn <&P_ST>,<ST(1)>
REG = 1
endif
ifidn <&P_ST>,<ST(2)>
REG = 2
endif
ifidn <&P_ST>,<ST(3)>
REG = 3
endif
ifidn <&P_ST>,<ST(4)>
REG = 4
endif
ifidn <&P_ST>,<ST(5)>
REG = 5
endif
ifidn <&P_ST>,<ST(6)>
REG = 6
endif
ifidn <&P_ST>,<ST(7)>
REG = 7
endif
ifidn <&P_ST>,<st(0)> ; Is i=0?
REG = 0
endif
ifidn <&P_ST>,<st(1)>
REG = 1
endif
ifidn <&P_ST>,<st(2)>
REG = 2
endif
ifidn <&P_ST>,<st(3)>
REG = 3
endif
ifidn <&P_ST>,<st(4)>
REG = 4
endif
ifidn <&P_ST>,<st(5)>
REG = 5
endif
ifidn <&P_ST>,<st(6)>
REG = 6
endif
ifidn <&P_ST>,<st(7)>
REG = 7
endif
;
; If i not between 0 or 7, see if actually an
; "ST(i)" or "ST(I)" string, indicating use of
; top of stack element
;
ifidn <&P_ST>,<ST(i)>
REG = 0
endif
ifidn <&P_ST>,<ST(I)>
REG = 0
endif
ifidn <&P_ST>,<st(i)>
REG = 0
endif
ifidn <&P_ST>,<st(I)>
REG = 0
endif
endm
;**********************************************************************;
;* ;
;* CHK_CONC - Simple macro that will automatically insert ;
;* WAIT statements AFTER every 8087 instruction ;
;* which accesses CPU main memory. If variable ;
;* "AUTOSYNC" <> 0, then these WAITs will be ;
;* inserted (providing no concurrency but relieving ;
;* the programmer from worrying about synchronizing ;
;* data references. If the user program sets ;
;* AUTOSYNC to a zero value, then no WAITs are ;
;* inserted after the instructions and it is ;
;* the user's responsibility to ensure synchro- ;
;* nization. ;
;* ;
;**********************************************************************;
CHK_CONC macro
if AUTOSYNC
WAIT ; Automatic syncronization
endif
endm
;**********************************************************************;
; ;
; CHOOSE_4 - Determine which of four parameters (XXX1 to XXX4) ;
; should be used in ESC sequence, depending on P1 ;
; and P2 values. P2 and P2 are parameters passed ;
; by user in macro call. XXX1 to XXX4 are macro- ;
; dependent parameters tacked on to the call to ;
; CHOOSE_4 by the specific 8087 macro called by the ;
; user code. ;
; ;
;**********************************************************************;
CHOOSE_4 macro P1,P2,XXX1,XXX2,XXX3,XXX4
; Initialize variables
ZERO = 0
NOTZERO = 0
REG = 0
;
; If user passed no parameters, (P1 and P2 are "blank") then
; issue a call to ESC_REG macro to set up proper ESC sequence.
; An arithmetic instruction with no operands is identical to the
; same instruction with the operand form "ST(1),ST".
; Example: "FDIV" - Divides second element of stack by first and
; places result in second element on stack.
;
ifb <P1>
REG = 1
ESC_REG XXX1,REG
else
;
; Check to see if first parameter (P1) passed by user is "ST".
; If yes, indecates that second parameter (P2) is of form "ST(i)"
; so use CHECK_ST macro to determine 'i'. Then call ESC_REG macro
; to issue ESC sequence.
; Example: "FADD ST,ST(4)" - Adds register four (fifth element on
; 8087 stack) to top element and leaves
; result on top of stack.
;
ifidn <P1>,<ST>
CHECK_ST P2
ZERO = REG + 1
ife ZERO
REG = 1
endi